<template>
	<view class="content">
		<image class="swiperImg" :src="Detail.pic_image" mode=""></image>
		<view class="detail">
			<view class="d_title">{{Detail.name}}</view>
			<view class="d_money">套餐价格：￥{{Detail.price}}元</view>
			<view class="d_desc">
				<view class="" v-for="(sitem,sindex) in Detail.product_label" :key="Sindex">{{sitem}}</view>
			</view>
		</view>
		<view class="">
			<view class="product-con">详细介绍</view>
			<view class="product">
				<view class="" v-html="Detail.product_content"></view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		req_ProductByShop,
		req_ProductById,
	} from '../../utls/api.js'
	export default {
		data() {
			return {
				Detail: uni.getStorageSync('Detail'),
				ShopList: []
			}
		},
		onLoad(e) {
			if (e.share_id) {
				uni.setStorageSync('share_id', e.share_id);
				console.log(e.share_id)
			}
		},
		onShow() {
			if (uni.getStorageSync('info').is_vip == 1) {
				uni.showShareMenu({
					withShareTicket: true,
					menus: ['shareAppMessage', 'shareTimeline'] //开启转发好友和转发朋友圈按钮
				});
			} else {
				uni.hideShareMenu({
					hideShareItems: ['shareTimeline', 'shareMenu']
				})
			}
		},
		onShareAppMessage: function(e) { // 分享到微信
			// 更多参数配置，参考文档
			let path = getCurrentPages();
			let route = path[path.length - 1].route;
			console.log(route, uni.getStorageSync('info').share_id)
			return {
				title: '同城泉友',
				path: `/${route}?share_id=${uni.getStorageSync('info').share_id}`,
			}
		},

		onShareTimeline() { // 分享到朋友圈
			let path = getCurrentPages();
			let route = path[path.length - 1].route;
			return {
				title: '同城泉友',
				path: `/${route}?share_id=${uni.getStorageSync('info').share_id}`,
			}
		},
		mounted() {
			console.log(uni.getStorageSync('Detail'));
			this.getProduct()
		},
		methods: {
			getProduct() {
				req_ProductById({
					id: this.Detail.id
				}).then(res => {
					if (res.data.code == 1) {
						console.log(res.data.data)
						this.ShopList = res.data.data;
					}
				})
			},
			goDetail(item) {
				uni.setStorageSync('Detail', item)
				uni.redirectTo({
					url: '../index/Detail',
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		background-color: #f1f1f1;
		padding-bottom: 20rpx;
		height: 100vh;
		overflow-y: scroll;
	}

	.swiperImg {
		width: 100%;
		height: 300rpx;
	}

	.detail {
		padding: 20rpx;
		background-color: white;
		margin: 20rpx;
		border-radius: 10rpx;

		.d_title {
			font-weight: 700;
			font-size: 30rpx;
		}

		.d_money {
			font-size: 26rpx;
			color: #EDB843;
			margin-top: 15rpx;
		}

		.d_desc {
			font-size: 20rpx;
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
			color: #999999;
			display: flex;
			margin-top: 5rpx;

			>view {
				padding: 5rpx 10rpx;
				border-radius: 8rpx;
				color: white;
				background-color: #EDB843;
				margin-right: 10rpx;
			}
		}
	}

	.Shop {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		padding: 20rpx;

		.Shop_item {
			width: 48%;
			margin: 20rpx 0;
			background-color: #f9f9f9;
			border-radius: 10rpx 10rpx 10rpx 10rpx;
			overflow: hidden;

			.Shop_img {
				width: 100%;
				height: 300rpx;
			}

			.Shop_text {
				padding: 10rpx 20rpx;

				.Shop_text_title {
					font-size: 30rpx;
					margin-bottom: 10rpx;
				}

				.Shop_money {
					display: flex;
					align-items: center;
					justify-content: space-between;
					font-size: 28rpx;
					color: red;
					text-align: center;

					.Shop_ymoney {
						text-decoration: line-through;
						color: #444444;
						font-size: 22rpx;
					}
				}
			}
		}
	}

	.host_list {
		display: flex;
		align-items: center;
		margin: 20rpx;
		padding: 10rpx;
		background-color: white;
		box-shadow: 0 0 30rpx 10rpx #f1f1f1;
		border-radius: 10rpx;

		.host_img {
			width: 150rpx;
			height: 150rpx;
			border-radius: 10rpx;
			min-width: 170rpx;
			margin-right: 20rpx;
		}

		.host_right {
			width: calc(100% - 170rpx);

			.r_title {
				font-size: 32rpx;
				font-weight: 600;
				margin-bottom: 10rpx;
			}

			.r_money {
				font-size: 28rpx;
				font-weight: 600;
				color: #EDB843;
				margin-top: 15rpx;
			}

			.r_desc {
				font-size: 22rpx;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
				color: #999999;
				display: flex;
				margin-top: 5rpx;

				>view {
					padding: 5rpx 10rpx;
					border-radius: 8rpx;
					color: white;
					background-color: #EDB843;
					margin-right: 10rpx;
				}
			}
		}
	}

	.product-con {
		font-size: 30rpx;
		font-weight: 600;
		padding: 0rpx 20rpx;
	}

	.product {
		margin: 20rpx;
		padding: 10rpx 20rpx;
		background-color: white;
		border-radius: 10rpx;
		// font-size: 26rpx;
		// color: #111;
	}
</style>